home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 July: Mac OS SDK / Dev.CD Jul 99 SDK1.toast / Development Kits / Mac OS / Telephone Manager / Stiletto Sources / ModuleSources / GetHooksw.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-06-26  |  3.1 KB  |  118 lines  |  [TEXT/MPS ]

  1. /************************************************************************************************/
  2. /*                                                                                                */
  3. /*    Module Name:    GetHooksw                                                                    */
  4. /*                                                                                                */
  5. /*    File Name:        GetHooksw.c                                                                    */
  6. /*                                                                                                */
  7. /*    © Apple Computer, Inc. 1991-1995                                                            */
  8. /*    All Rights Reserved                                                                            */
  9. /*                                                                                                */
  10. /*    Revision History:                                                                            */
  11. /*                                                                                                */
  12. /*        Date        Who                    Modification                                            */
  13. /*                                                                                                */
  14. /*        1991-08-13    Chris Halim            Original version                                        */
  15. /*        1995-06-26    Jaakko Railo        Version 2.0                                                */
  16. /*                                                                                                */
  17. /************************************************************************************************/
  18.  
  19. /****************************************** DESCRIPTION ******************************************
  20.  
  21. *************************************************************************************************/
  22.  
  23. /******************************************** HEADERS *******************************************/
  24.  
  25. #include "TextUtils.h"
  26.  
  27. #ifndef __TELEPHONES__
  28. #include "Telephones.h"
  29. #endif
  30.  
  31. #include "TestModule.h"
  32.  
  33. /****************************************** DEFINITIONS *****************************************/
  34.  
  35. #define    rGetANumberDLOG        10000
  36. #define    kNumber                3
  37.  
  38. /****************************************** PROTOTYPES ******************************************/
  39.  
  40. short    GetANumber (short * htype);
  41. void     DoTest (CHRSPtr paramPtr);
  42.  
  43. /************************************************************************************************/
  44. /************************************************************************************************/
  45.  
  46.  
  47. pascal short TestModule (CHRSPtr paramPtr)
  48. {
  49.     short    returnValue = noErr;
  50.     
  51.     if (paramPtr->version <= kTestModuleVersion) {
  52.         
  53.         DoTest (paramPtr);
  54.         
  55.     }
  56.     else
  57.         returnValue = kWrongVersion;
  58.         
  59.     return (returnValue);
  60. }
  61.  
  62.  
  63. short    GetANumber (short * number)
  64. {
  65.     short        itemKind;
  66.     Handle        itemHand;
  67.     Rect        itemRect;
  68.     short        itemHit;
  69.     DialogPtr    theDialog;
  70.     Str255        itemStr;
  71.     long        tlong;
  72.     
  73.     if ((theDialog = GetNewDialog (rGetANumberDLOG, nil, (WindowPtr)(-1L))) != nil) {
  74.         GetDItem (theDialog, kNumber, &itemKind, &itemHand, &itemRect);
  75.         SelIText (theDialog, kNumber, 0, 32767);
  76.         
  77.         ShowWindow (theDialog);
  78.         
  79.         ModalDialog (nil, &itemHit);
  80.         
  81.         if (itemHit == ok) {
  82.             GetDItem (theDialog, kNumber, &itemKind, &itemHand, &itemRect);
  83.             GetIText (itemHand, itemStr);
  84.             StringToNum (itemStr, &tlong);
  85.             *number = tlong;
  86.         }
  87.         
  88.         DisposeDialog (theDialog);
  89.     }
  90.     else
  91.         itemHit = -1;
  92.     
  93.     return (itemHit);
  94. }
  95.  
  96.  
  97. void DoTest (CHRSPtr paramPtr)
  98. {
  99.     TELHandle    termHand = GetCurrentTELHandle (paramPtr);
  100.     short        itemHit, htype;
  101.     OSErr        errCode;
  102.     Boolean        onHook;
  103.     
  104.     if ((itemHit = GetANumber (&htype)) == ok) {
  105.         
  106.         if ((errCode = TELGetHooksw (termHand, htype, &onHook)) == noErr)
  107.             Print (paramPtr, "TELGetHooksw --> hookState = %s", 
  108.                     ((onHook==telDeviceOnHook)?"telDeviceOnHook":"telDeviceOffHook"));
  109.         else
  110.             Print (paramPtr, "### TELGetHooksw failed : %d", errCode);
  111.     }
  112.     else
  113.         if (itemHit == -1)
  114.             Print (paramPtr, "### Unable to get a DLOG resource");
  115. }
  116.  
  117.  
  118.